package com.guangdujs.kis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guangdujs.common.annotation.Log;
import com.guangdujs.common.core.controller.BaseController;
import com.guangdujs.common.core.domain.AjaxResult;
import com.guangdujs.common.enums.BusinessType;
import com.guangdujs.kis.domain.GdStock;
import com.guangdujs.kis.service.IGdStockService;
import com.guangdujs.common.utils.poi.ExcelUtil;
import com.guangdujs.common.core.page.TableDataInfo;

/**
 * 即时库存Controller
 */
@RestController
@RequestMapping("/kis/Stock")
public class GdStockController extends BaseController
{
    @Autowired
    private IGdStockService gdStockService;

    /**
     * 查询即时库存列表
     */
    @PreAuthorize("@ss.hasPermi('kis:Stock:list')")
    @GetMapping("/list")
    public TableDataInfo list(GdStock gdStock)
    {
        startPage();
        List<GdStock> list = gdStockService.selectGdStockList(gdStock);
        return getDataTable(list);
    }

    /**
     * 导出即时库存列表
     */
    @PreAuthorize("@ss.hasPermi('kis:Stock:export')")
    @Log(title = "即时库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GdStock gdStock)
    {
        List<GdStock> list = gdStockService.selectGdStockList(gdStock);
        ExcelUtil<GdStock> util = new ExcelUtil<GdStock>(GdStock.class);
        util.exportExcel(response, list, "即时库存数据");
    }

    /**
     * 产品品种总数
     */
    @GetMapping("/selectGoodsClassNum")
    public AjaxResult selectGoodsClassNum(){
        return AjaxResult.success(gdStockService.selectGoodsClassNum());
    }

    /**
     * 产品名称列表
     */
    @GetMapping("/selectGoodsNameList")
    public AjaxResult selectGoodsNameList(){
        return AjaxResult.success(gdStockService.selectGoodsNameList());
    }

}
